package cn.hfjava.kz.test;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;

@Slf4j
public class  WordReplacer {




    public static void main(String[] args) throws IOException {
        String userDir = System.getProperty("user.dir");
        log.info("获取该项目在系统在的绝对路径:{}", userDir);
        // 模板文件路径
        String srcPath = userDir + "\\Template.docx";
        // 输出结果文件路径
        String destPath = userDir + "\\刘垛生.docx";

        // 替换内容集合
        Map<String, String> textMap = new LinkedHashMap<>();
        textMap.put("name","刘垛生");
        textMap.put("sex","男");
        textMap.put("birth","1985.09.30");
        textMap.put("education","大学本科");

        WordUtils.replaceText(srcPath, destPath, textMap);
        System.out.println("操作完毕");
    }
}
